package p9.code;

public class InterruptThreadStudy {

    public static void main(String[] args) {

        Thread a =  new Thread(()->{
            try {
                Thread.sleep(1000000);
            } catch (InterruptedException e) {
                System.out.println("线程A的sleep方法中断！！");
                Thread.currentThread().interrupt();
                System.out.println("线程A继续执行");
            }
        });
        a.start();

        Thread b = new Thread(()->{
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            // 这里线程b尝试中断线程a
            a.interrupt();
        });
        b.start();

    }
}